/*
 * Copyrignt (c) xuzeshui.com. All Rights Reserved.
 * Author: Xiaobao Zeng<zengxiaobao@skyworth.com>
 * Created Time: 2016-12-16 18:08:11
 * Last Modified: 2017-08-01 19:31:38
 * File Name: qingke.go
 * Description:
 */

package qingke

import (
	"crypto/tls"
	"fmt"

	"doubimeizhi.com/utility"
	"github.com/astaxie/beego/httplib"
	log "github.com/cihub/seelog"
)

//根据洗衣机编号群和特定条件查询订单详情
func GetOrdersByWasherIds(data interface{}) (bool, interface{}) {
	nusb := utility.NewURLSignBuilder(qkAppkey, qkSecret, fmt.Sprintf("https://%s/payment/washing/orders-list-washerids", qkHost))
	reqURL := nusb.BuildURL()
	//reqURL := fmt.Sprintf("https://%s//payment/washing/orders-list-washerids?appkey=271d8700b1074a9582a8cc4cdff94c5f", qkHost)
	b := httplib.Post(reqURL)
	b.SetHost(qkHost)
	b.JSONBody(data)
	b.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
	resp := make(map[string]interface{})
	if err := b.ToJSON(&resp); err != nil {
		log.Errorf("rpc-qingke-GetOrdersByWasherIds, service page not found, url:%d", reqURL)
		return false, nil
	}
	if int(resp["code"].(float64)) == 0 {
		if orders, ok := resp["data"]; ok {
			return true, orders
		}
		return true, nil
	}
	log.Warnf("rpc-qingke-GetOrdersByWasherIds,resp err, code:%v, msg:%v", resp["code"], resp["msg"])
	return false, nil
}
